<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>本地应用</title>
<link rel="icon" href="favicon.ico" type="image/ico">
{sys:load href="admin/css/bootstrap.min.css,admin/css/materialdesignicons.min.css,admin/css/style.min.css"}
</head>

<body>
<div class="container-fluid p-t-15">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-header"><h4>本地应用</h4></div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>#</th>
                  <th>应用名称</th>
                  <th>应用标识</th>
                  <th>作者</th>
                  <th>版本</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                  {volist name="appins" id="appin"}
                <tr>
                  <th scope="row">{$i}</th>
                  <td>{$appin.name}</td>
                  <td>{$appin.tag_name}</td>
                  <td>{$appin.author}</td>
                  <td>{$appin.version}</td>
                  <td>
                      <a href="javascript:void(0)" class="btn btn-xs btn-default m-r-5 install-app" title="安装" data-toggle="tooltip" data-tag="{$appin.tag_name}">
                          <i class="mdi mdi-pencil">安装应用</i>
                      </a>
                  </td>
                </tr>
                {/volist}

              </tbody>
            </table>
          </div>

        </div>
      </div>
    </div>
  </div>

</div>

{sys:load href="admin/lib/layui/layui.js,admin/common.js"}
<script type="text/javascript">
layui.use(['jquery', 'Request', 'layer'], function(){
    var $ = layui.jquery,Request = layui.Request, layer = layui.layer;
    $(".install-app").on('click', function(){
        let tagName = $(this).data('tag');
        Request.get('/admin/appin/install', {tag: tagName}, function(response){
            let jumpUri = response.data.install_uri;
            if (jumpUri) {
                window.location.href = jumpUri;
            } else {
                layer.msg('安装成功', function(){
                    window.location.reload();
                })
            }
        })
    })
})
</script>
</body>
</html>
